import axios from "axios";
import baseUrl from "../baseUrl";
import md5 from "js-md5"
export default{
    namespaced: true,
    state:{
        code:-1,
        message:""
    },
    actions:{
        reset(context, data){
            console.log(data);
            axios
              .get(`${baseUrl}user/Reset`, {
                params: {
                  username: data.username,
                  password: md5(data.password),
                  answer:md5(data.answer)
                },
              })
              .then((response) => {
                console.log(response.data);
                context.commit("RESET", response.data);
                return response.data;
              })
              .catch((error) => {
                console.log(error.message);
              });

        }
    },
    mutations: {
        RESET(state, data){
            state.code=data.state
            state.message= data.message
            console.log(state);
        }

    }

}